package com.koron.css2.baseConfig.mapper;

import com.koron.css2.baseConfig.bean.BaseDmaAreaBean;
import com.koron.css2.baseConfig.bean.query.BaseDmaAreaQueryBean;
import com.koron.css2.baseConfig.vo.SelectVO;
import com.koron.css2.serviceManage.bean.SelectBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BaseDmaAreaMapper {


    /**
     * 营业所下拉框
     */
    public List<SelectVO> select(@Param("id") String id, @Param("dmaAreaNo") String dmaAreaNo);



    List<BaseDmaAreaBean> selectBaseDmaAreaList(BaseDmaAreaQueryBean selectBean);


    @Select("select * from base_dma_area where id =#{id}")
    BaseDmaAreaBean findBaseDmaAreaInfoById(@Param("id") String id);


    /**
     * 根据ID查询营业区域信息
     * @param id
     * @return
     */
    public String findBaseDmaAreaById(@Param("id") String id);

    /**
     * 校验字段内容重复
     */
    @Select("select count(*) from base_dma_area where ${key} = #{val}")
    Integer check(@Param("key") String key, @Param("val") String val);


    /**
     * 根据父ID查询营业区域信息
     * @param
     * @return
     */
    public List<SelectBean> findBaseDmaAreaByIdByParentId(@Param("parentId") String parentId);


    /**
     * 根据父编号查询营业区域信息
     * @param
     * @return
     */
    public List<String> findAllByParentNo(@Param("dmaAreaNo") String dmaAreaNo);


    /**
     * 校验字段内容重复-排除当前记录
     */
    @Select("select count(*) from base_dma_area where ${key} = #{val} and id <> #{id}")
    Integer check2(@Param("key") String key, @Param("val") String val, @Param("id") String id);


    Integer insertBaseDmaArea(BaseDmaAreaBean bean);


    @Select("select * from base_dma_area where id =#{id}")
    BaseDmaAreaBean findbaseDmaAreaById(@Param("id") String id);

    Integer updateBaseDmaArea(BaseDmaAreaBean bean);


    String getIdByAreaName(@Param("dmaAreaName") String dmaAreaName);


    BaseDmaAreaBean getSingle(BaseDmaAreaQueryBean baseDmaAreaQuery);

}
